export default{
    state:{
        username:'',
        status:0,
        is_seller:0,
        // session_id:''
    },
    //计算属性
    getters:{
        isLogin(state){
            return state.status !==0;
        },
        isSeller(state){
            if(state.is_seller===0){
                return '用户';
            }else{
                return '商家';
            }
        },
        set_is_seller(state){
            state.is_seller=1;
        },
    },
    mutations:{
        setUser(state,user){
            state.username=user.usernmae;
            state.status=user.status;
            state.is_seller=user.is_seller;
            // state.session_id=user.seeeion_id;
        },
        
        login_out(state){
            state.status=0
            state.username='',
            state.is_seller=''
        }
    },
    
    actions:{
        asyncUpdateUser(context,user){
            context.commit('setUser',user);
        }
    },
    
    namespaced:true
}


